// 从插件内导出createRouter、createWebHashHistory
import { createRouter ,createWebHashHistory } from "vue-router";
import LoginCom from "@/components/LoginCom.vue";
import HomeCome from "@/components/HomeCom.vue";
    import AddPerson from "@/components/home/AddPerson.vue";
    import ListPerson from "@/components/home/ListPerson.vue";
    import ShoolList from "@/components/home/ShoolList";
    import ProductList from "@/components/home/ProductList";

// 定义路由表
const routes =[
    {
        path : '/',

        redirect : 'logins',
    },
    {
        path : '/logins',

        name : "LoginCom",

        component : LoginCom
    },
    {
        path : '/home',

        name : "HomeCom",

        component : HomeCome,

        // 首页的子路由
        children :[
            {
                path : 'addperson',
                name : 'AddPerson',
                component : AddPerson
            },
            {
                path : 'listperson',
                name : 'ListPerson',
                component : ListPerson
            },
            {
                path : 'shoollist',
                name : 'ShoolList',
                component : ShoolList
            },
            {
                path : 'productlist',
                name : 'ProductList',
                component : ProductList
            },
        ]
    },
];
// 定义路由器/创建路由器
const router = createRouter({
    // 调用路由表，实现router-link的跳转以及router-view的渲染
    // routes : routes,
    routes,

    // 将路由历史模式设置为hash模式（哈希历史）
    history : createWebHashHistory(),
});

// 导出路由器
export default router;